//package com.example.demo.kafka;
//
//import org.apache.flink.api.common.functions.FlatMapFunction;
//import org.apache.flink.api.java.tuple.Tuple2;
//import org.apache.flink.streaming.api.datastream.DataStream;
//import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
//import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer;
//import org.apache.flink.streaming.util.serialization.SimpleStringSchema;
//import org.apache.flink.util.Collector;
//
//import java.util.Properties;
//
//public class FilnkCostKafka {
//    public static void main(String[] args) throws Exception {
//        final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
//        env.enableCheckpointing(1000);
//
//        Properties properties = new Properties();
//        properties.setProperty("bootstrap.servers", "192.168.1.20:9092");
//        properties.setProperty("zookeeper.connect", "192.168.1.20:2181");
//        properties.setProperty("group.id", "test");
//
//        FlinkKafkaConsumer<String> myConsumer = new FlinkKafkaConsumer<>("test", new SimpleStringSchema(), properties);
//
//
//        DataStream<String> stream = env.addSource(myConsumer);
//        DataStream<Tuple2<String, Integer>> counts = stream.flatMap(new LineSplitter()).keyBy(0).sum(1);
//
//    }
//
//    public static final class LineSplitter implements FlatMapFunction<String, Tuple2<String, Integer>> {
//        private static final long serialVersionUID = 1L;
//
//        public void flatMap(String value, Collector<Tuple2<String, Integer>> out) {
//            String[] tokens = value.toLowerCase().split("\\W+");
//            for (String token : tokens) {
//                if (token.length() > 0) {
//                    out.collect(new Tuple2<String, Integer>(token, 1));
//                }
//            }
//        }
//    }
//
//
//}